package com.ai.dmc.index.web.action;


import java.io.InputStream;

import com.ai.dmc.index.common.InitParam;
import com.ai.dmc.index.common.bean.StaffSessBean;
import com.ai.dmc.index.web.agent.utils.HttpUtils;
import com.ai.dmc.index.web.util.SessionInfoUtil;
import com.ai.frame.bean.InputObject;
import com.ai.frame.bean.OutputObject;
import com.ai.frame.logger.Logger;
import com.ai.frame.logger.LoggerFactory;
import com.ai.frame.util.ConvertUtil;
import com.ai.frame.util.JsonUtil;

/**
 */
public class AgentAction extends BaseAction {
	private static final long serialVersionUID = 2021751417577646314L;
	private static final Logger logger = LoggerFactory.getActionLog(AgentAction.class);
	
	
	private StaffSessBean session;
	private String userId;
	private boolean isAdmin;
	private String areaId;
	/**
	 * 
	 * @Description : 初始化
	 * @return void
	 * 
	 * @author : wucm
	 * @date : 2015年7月10日 上午9:41:28
	 * 
	 */
	public void init() {
		session = SessionInfoUtil.getStaffSessBean(
				this.getRequest().getSession());
		userId = session.getUserId();
		isAdmin = session.isAdmin();
		areaId = session.getAreaId();
	}
	
	/** Uniform Method Invocation **/
	public String execute() {
		logger.info("execute", "Start");
		this.init();
		InputObject inputObject = super.getInputObject();
		inputObject.getParams().put("userId", userId);
		inputObject.getParams().put("isAdmin", String.valueOf(isAdmin));
		inputObject.getParams().put("areaId", areaId);
//		OutputObject object = super.getOutputObject();
		String url = "http://api.map.baidu.com/telematics/v3/weather?location=合肥&output=json&ak=BotOjSIxOHZGQwVYqKX3LX7t&callback=xxx";
//		url = inputObject.getParams().get("url");
		String content = HttpUtils.sendGet(url, "");
		super.sendJson(content);
		logger.info("execute", "End");
		return null;
	}
	
	public String defaultGet() {
		logger.info("execute", "Start");
		this.init();
		InputObject inputObject = super.getInputObject();
		inputObject.getParams().put("userId", userId);
		inputObject.getParams().put("isAdmin", String.valueOf(isAdmin));
		inputObject.getParams().put("areaId", areaId);
//		OutputObject object = super.getOutputObject();
//		String url = "http://api.map.baidu.com/telematics/v3/weather?location=合肥&output=json&ak=BotOjSIxOHZGQwVYqKX3LX7t&callback=xxx";
		String url = inputObject.getParams().get("url");
		String content = HttpUtils.sendGet(url, "");
		super.sendJson(content);
		logger.info("execute", "End");
		return null;
	}
}
